package dto;

import java.util.HashMap;
import java.util.Map;

import models.CategoryNode;

public class NodeDto {
	public Map<String, String> attr;
	public String data;
	public String state;

	public static NodeDto convert(CategoryNode node) {
		NodeDto nodeDto = new NodeDto();
		Map<String, String> attr = new HashMap<String, String>();
		attr.put("id", "node_" + node.id);
		attr.put("rel", node.type);
		nodeDto.attr = attr;
		nodeDto.data = node.title;
		nodeDto.state = node.right - node.left > 1 ? "closed" : "";
		return nodeDto;
	}
}
